// RUN: XDSL_ROUNDTRIP
// RUN: XDSL_GENERIC_ROUNDTRIP

// CHECK-GENERIC:      %cst_f64 = "complex.constant"() <{value = [1.000000e-01 : f64, -1.000000e+00 : f64]}> : () -> complex<f64>
// CHECK-GENERIC-NEXT: %cst_f32 = "complex.constant"() <{value = [1.000000e-01 : f32, -1.000000e+00 : f32]}> : () -> complex<f32>
// CHECK-GENERIC-NEXT: %cst_i1 = "complex.constant"() <{value = [true, false]}> : () -> complex<i1>
// CHECK-GENERIC-NEXT: %complex = "complex.create"(%f, %f) : (f32, f32) -> complex<f32>
// CHECK-GENERIC-NEXT: %real = "complex.re"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> f32
// CHECK-GENERIC-NEXT: %imag = "complex.im"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> f32
// CHECK-GENERIC-NEXT: %abs = "complex.abs"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> f32
// CHECK-GENERIC-NEXT: %sum = "complex.add"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %cos = "complex.cos"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %div = "complex.div"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %eq = "complex.eq"(%complex, %complex) : (complex<f32>, complex<f32>) -> i1
// CHECK-GENERIC-NEXT: %exp = "complex.exp"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %expm1 = "complex.expm1"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %log = "complex.log"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %log1p = "complex.log1p"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %prod = "complex.mul"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %neg = "complex.neg"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %neq = "complex.neq"(%complex, %complex) : (complex<f32>, complex<f32>) -> i1
// CHECK-GENERIC-NEXT: %sign = "complex.sign"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %sin = "complex.sin"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %diff = "complex.sub"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %tanh = "complex.tanh"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %pow = "complex.pow"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %sqrt = "complex.sqrt"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %rsqrt = "complex.rsqrt"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %atan2 = "complex.atan2"(%complex, %complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>, complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %tan = "complex.tan"(%complex) <{fastmath = #arith.fastmath<none>}> : (complex<f32>) -> complex<f32>
// CHECK-GENERIC-NEXT: %i64 = "complex.bitcast"(%complex) : (complex<f32>) -> i64
// CHECK-GENERIC-NEXT: "func.return"() : () -> ()

// CHECK-LABEL: func @ops(
// CHECK-SAME:            %[[F:.*]] : f32) {
func.func @ops(%f: f32) {
  // CHECK: complex.constant [1.{{.*}}, -1.{{.*}}] : complex<f64>
  %cst_f64 = complex.constant [0.1, -1.0] : complex<f64>

  // CHECK: complex.constant [1.{{.*}} : f32, -1.{{.*}} : f32] : complex<f32>
  %cst_f32 = complex.constant [0.1 : f32, -1.0 : f32] : complex<f32>

  // CHECK: complex.constant [true, false] : complex<i1>
  %cst_i1 = complex.constant [1 : i1, 0 : i1] : complex<i1>

  // CHECK: %[[C:.*]] = complex.create %[[F]], %[[F]] : complex<f32>
  %complex = complex.create %f, %f : complex<f32>

  // CHECK: complex.re %[[C]] : complex<f32>
  %real = complex.re %complex : complex<f32>

  // CHECK: complex.im %[[C]] : complex<f32>
  %imag = complex.im %complex : complex<f32>

  // CHECK: complex.abs %[[C]] : complex<f32>
  %abs = complex.abs %complex : complex<f32>

  // CHECK: complex.add %[[C]], %[[C]] : complex<f32>
  %sum = complex.add %complex, %complex : complex<f32>

  // CHECK: complex.cos %[[C]] : complex<f32>
  %cos = complex.cos %complex : complex<f32>

  // CHECK: complex.div %[[C]], %[[C]] : complex<f32>
  %div = complex.div %complex, %complex : complex<f32>

  // CHECK: complex.eq %[[C]], %[[C]] : complex<f32>
  %eq = complex.eq %complex, %complex : complex<f32>

  // CHECK: complex.exp %[[C]] : complex<f32>
  %exp = complex.exp %complex : complex<f32>

  // CHECK: complex.expm1 %[[C]] : complex<f32>
  %expm1 = complex.expm1 %complex : complex<f32>

  // CHECK: complex.log %[[C]] : complex<f32>
  %log = complex.log %complex : complex<f32>

  // CHECK: complex.log1p %[[C]] : complex<f32>
  %log1p = complex.log1p %complex : complex<f32>

  // CHECK: complex.mul %[[C]], %[[C]] : complex<f32>
  %prod = complex.mul %complex, %complex : complex<f32>

  // CHECK: complex.neg %[[C]] : complex<f32>
  %neg = complex.neg %complex : complex<f32>

  // CHECK: complex.neq %[[C]], %[[C]] : complex<f32>
  %neq = complex.neq %complex, %complex : complex<f32>

  // CHECK: complex.sign %[[C]] : complex<f32>
  %sign = complex.sign %complex : complex<f32>

  // CHECK: complex.sin %[[C]] : complex<f32>
  %sin = complex.sin %complex : complex<f32>

  // CHECK: complex.sub %[[C]], %[[C]] : complex<f32>
  %diff = complex.sub %complex, %complex : complex<f32>

  // CHECK: complex.tanh %[[C]] : complex<f32>
  %tanh = complex.tanh %complex : complex<f32>

  // CHECK: complex.pow %[[C]], %[[C]] : complex<f32>
  %pow = complex.pow %complex, %complex : complex<f32>

  // CHECK: complex.sqrt %[[C]] : complex<f32>
  %sqrt = complex.sqrt %complex : complex<f32>

  // CHECK: complex.rsqrt %[[C]] : complex<f32>
  %rsqrt = complex.rsqrt %complex : complex<f32>

  // CHECK: complex.atan2 %[[C]], %[[C]] : complex<f32>
  %atan2 = complex.atan2 %complex, %complex : complex<f32>

  // CHECK: complex.tan %[[C]] : complex<f32>
  %tan = complex.tan %complex : complex<f32>

  // CHECK: complex.bitcast %[[C]]
  %i64 = complex.bitcast %complex : complex<f32> to i64

  return
}
